package com.ygou.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ygou.pojo.Log;
import com.ygou.utils.AppendContentToFile;

@Controller
@RequestMapping(value="/log")
public class LogControlleer {
	@RequestMapping("/show")
	public String show(Integer currPage,String selDater,ModelMap model){
		if(currPage==null||currPage==0){
			currPage=1;
		}
		int pageSize=20;
		String fileName=selDater+".txt";
		List<Log> logs=AppendContentToFile.read(fileName);
//		int count=logs.size();
//		int pageCount=count%pageSize==0?count/pageSize:count/pageSize+1;
//		int first=(currPage-1)*pageSize;
//		int last=currPage*pageSize-1;
//		List<Log> showLog=new ArrayList<Log>();
//		for (int i = first; i <= last; i++) {
//			showLog.add(logs.get(i));
//		}
		model.put("selDate", selDater);
		model.put("pageCount", 0);
		model.put("lls", logs);
		model.put("currPage",0);
		return "admin/System_Logs";
	}
}
